find_package(CUDA REQUIRED)
message(STATUS "cuda version: " ${CUDA_VERSION_STRING})
include_directories(${CUDA_INCLUDE_DIRS})

find_package(OpenCV REQUIRED)
message(STATUS "OpenCV version: " ${OpenCV_VERSION})

set(TENSORRT_ROOT ${3rdParty_dir}/tensorrt)
link_directories(${TENSORRT_ROOT}/lib)

find_package(plog CONFIG REQUIRED)
message(STATUS "plog version: " ${plog_VERSION})

function(link_opencv target_name)
    target_link_libraries(${target_name}      PRIVATE ${OpenCV_LIBS})
    target_include_directories(${target_name} PRIVATE ${OpenCV_INCLUDE_DIRS})
endfunction()

function(link_tensorrt target_name)
    target_include_directories(${target_name} PRIVATE ${TENSORRT_ROOT}/include)
    target_link_libraries(${target_name} nvinfer nvinfer_plugin nvparsers nvonnxparser)
endfunction()

function(link_plog target_name)
    target_link_libraries(${target_name} PRIVATE plog::plog)
endfunction()

function(link_cuda_trt target_name)
    message(STATUS "link_cuda_trt: ${target_name}")
    target_link_libraries(${target_name} PRIVATE nvinfer nvinfer_plugin nvparsers nvonnxparser)
    target_link_libraries(${target_name} PRIVATE ${CUDA_LIBRARIES})
    target_link_libraries(${target_name} PUBLIC plog::plog)
    target_include_directories(${target_name} PUBLIC ${TENSORRT_ROOT}/include)
    set_target_properties( ${target_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endfunction()

function(add_export_define target_name)
    target_compile_definitions(${target_name} PRIVATE -DPI_API_EXPORTS)
endfunction()

